import {Document, Schema, Model, model} from "mongoose";
import {Games} from "../types/gamesType";

interface GamesDocument extends Document, Games {
}

const GamesSchema: Schema = new Schema({
    name: {
        type: String,
        required: true
    },
    appid: {
        type: String,
        required: true,
        unique: true
    },
    secret: {
        type: String,
        required: true
    },
    config: {
        type: Object,
        default: {
            video: 999,
            ip: ['127.0.0.0']
        }
    },
    token: {
        type: Object,
        default: {
            access_token: '',
            expires_at: '',
            expires_in: ''
        }
    }
});

export const GamesModel: Model<GamesDocument> = model<GamesDocument>('Games', GamesSchema)